
const arr: any[string] = []
const homeDom: any = document.querySelector('.home_loading')
let time: any = null

const isLoading = (type: number, name: string) => {
    if (type === 1) {
        arr.push(name)
    } else {
        const index = arr.findIndex((item: string) => {
            return item === name
        })
        if (index !== -1) {
            arr.splice(index, 1)
        }
    }
    if (arr.length) {
        if (homeDom.classList.contains('is_home_loading')) {
            homeDom.classList.remove('is_home_loading');
        }
    } else {
        if (time) {
            clearTimeout(time)
        }
        time = setTimeout(() => {
            homeDom.classList.add('is_home_loading');
        }, 500)
    }
}
export default isLoading